pp108 : Using SAML Artifact

Using SAML Artifact

This topic provides samples for using SAML artifacts in your application.

Before you begin this task: You must send a request to the identity provider to get a SAML assertion containing a SAML artifact. To view a sample request, refer to SAML Assertion Request and to view its response, refer to SAML Assertion Response. The SAML artifact in the response is as follows:

<samlp:AssertionArtifact xmlns:samlp="urn:oasis:names:tc:SAML:1.0:protocol">
        MDF3eiA3HTMvRoDydILiGLihWu7akA65UvZOe0p5hka4siLYQInR/N1C
</samlp:AssertionArtifact>


This SAML artifact can be used as URL parameter. To use the SAML Artifact as an URL parameter you must encode it as a URl parameter and then add it to the URL itself.

  1. The following Javascript sample code encodeURI() with the URL variable name SAMLart encodes the artifact to URL:
    function addParameterToURL(url, name, value) 
    {
      var questionMarkPosition = url.indexOf("?");
      var addAmpersand = questionMarkPosition>=0 &amp;&amp; questionMarkPosition<url.length-1 &amp;&amp; ! /&amp;$/.test(url);
      var addQuestionMark = questionMarkPosition<=0;
      if (addQuestionMark) url += "?";
      if (addAmpersand) url += "&amp;";
      url += name + "=" + encodeURIComponent(value);
      return url; 
    }
  2. The following sample code invokes the function encodeURI():
    addParameterToURL(url, 'SAMLart' , samlArtifactFromRequest);

    The sample URL returned is http://srv-nl-sso1/test/com.eibus.web.soap.Gateway.wcp?SAMLart=MDF3eiA3HTMvRoDydILiGLihWu7akA65UvZOe0p5hka4siLYQInR%2FN1C.
    This URL can be used in any request to the Web server.

Related information

Managing Web Gateway